package com.indra.archetypeweb.dao.product;

import java.util.List;

import javax.persistence.PersistenceException;

import com.indra.archetypeweb.dao.base.BaseDaoImpl;
import com.indra.archetypeweb.entity.product.Product;
import com.indra.archetypeweb.entity.user.User;

public class ProductDaoImpl extends BaseDaoImpl<Product> implements ProductDao {

	@Override
	public List<Product> findAll() {
		
		return em.createNamedQuery(Product.FIND_ALL, Product.class).getResultList();
	}

	@Override
	public List<Product> findByType(int productType) {
		
		try {
			return em.createNamedQuery(Product.FIND_BY_TYPE, Product.class)
					.setParameter("productType", productType).getResultList();
		} catch (PersistenceException e) {
			return null;
		}
	}

}
